package com.dnjn.happiness.cms.service.impl;

import java.time.LocalDateTime;
import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dnjn.happiness.cms.mapper.ArticleMapper;
import com.dnjn.happiness.cms.domain.Article;
import com.dnjn.happiness.cms.service.IArticleService;

/**
 * 文章管理Service业务层处理
 * 
 * @author amber
 * @date 2023-10-10
 */
@Service
public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> implements IArticleService
{
    @Autowired
    private ArticleMapper articleMapper;

    /**
     * 查询文章管理
     * 
     * @param articleId 文章管理主键
     * @return 文章管理
     */
    @Override
    public Article selectArticleByArticleId(Long articleId)
    {
        return articleMapper.selectArticleByArticleId(articleId);
    }

    /**
     * 查询文章管理列表
     * 
     * @param article 文章管理
     * @return 文章管理
     */
    @Override
    public List<Article> selectArticleList(Article article)
    {
        return articleMapper.selectArticleList(article);
    }

    /**
     * 新增文章管理
     * 
     * @param article 文章管理
     * @return 结果
     */
    @Override
    public int insertArticle(Article article)
    {
        article.setCreateTime(LocalDateTime.now());
        return articleMapper.insertArticle(article);
    }

    /**
     * 修改文章管理
     * 
     * @param article 文章管理
     * @return 结果
     */
    @Override
    public int updateArticle(Article article)
    {
        article.setUpdateTime(LocalDateTime.now());
        return articleMapper.updateArticle(article);
    }

    /**
     * 批量删除文章管理
     * 
     * @param articleIds 需要删除的文章管理主键
     * @return 结果
     */
    @Override
    public int deleteArticleByArticleIds(Long[] articleIds)
    {
        return articleMapper.deleteArticleByArticleIds(articleIds);
    }

    /**
     * 删除文章管理信息
     * 
     * @param articleId 文章管理主键
     * @return 结果
     */
    @Override
    public int deleteArticleByArticleId(Long articleId)
    {
        return articleMapper.deleteArticleByArticleId(articleId);
    }

    @Override
    public int updateArticleDeleteByArticleIds(Long[] articleIds) {
        return articleMapper.updateArticleDeleteByArticleIds(articleIds);
    }
}
